<?php
/**
 * ＺＥＮＤパーシャルライブラリ
 * セレクトメニュー
 */
require_once __DIR__ . '/../ZendPartial.php';

class ZendPartial_SelectController extends ZendPartialController
{
	const NAME_TEMPLATE_FILE = 'select.tpl';
	const KEY_VALUE = 'VALUE';
	const KEY_LABEL = 'LABEL';

	protected $_LabelList = array();

	public function __construct($Name)
	{
		parent::__construct(__DIR__);
		$this->view->NAME = $Name;
		$this->_setHttpRequestValue();
	}

	public function add($Label, $Value)
	{
		$this->_LabelList[]
		= array(
				self::KEY_LABEL=>$Label,
				self::KEY_VALUE=>$Value
				);
	}

	public function fetch($TemplateFileName='')
	{
		if ($TemplateFileName == '') {
			$TemplateFileName = self::NAME_TEMPLATE_FILE;
		}

		$this->view->OPTION_LIST = $this->_LabelList;

		$sHtml = parent::fetch($TemplateFileName);
		return $sHtml;
	}

	protected function _setHttpRequestValue()
	{
		if (isset($_REQUEST[$this->view->NAME])){
			$this->view->HTTP_REQUEST_VALUE = $_REQUEST[$this->view->NAME];
		}
	}
}